package com.controller;

import com.entity.GroupMessage;
import com.github.pagehelper.PageInfo;
import com.service.GroupMessageService;
import com.vo.ResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api")
public class GroupMessageController {
    @Autowired
    private GroupMessageService groupMessageService;

    @GetMapping("/groupMessage")
    public ResponseVO getByGroupId(Integer groupId){
        List<GroupMessage> result = groupMessageService.getByGroupId(groupId);
        return new ResponseVO("200",null,result);
    }
    @GetMapping("/groupMessage/all")
    public ResponseVO getAllByGroupId(Integer pageNum,Integer pageSize,Integer groupId){
        List<GroupMessage> result = groupMessageService.getAllByGroupId(pageNum,pageSize,groupId);
        PageInfo pageInfo = new PageInfo(result);
        return new ResponseVO("200",null,pageInfo);
    }

}
